//
//  SpeakTwo.m
//  HYHOME
//
//  Created by dllo on 16/2/25.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "SpeakTwoCell.h"
#import "SpeakModel.h"
#import "UIImageView+WebCache.h"
#import "DKNightVersion.h"



#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height


@implementation SpeakTwoCell


- (void)dealloc{

    [_image_urls release];
    [_icon_url release];
    [_name release];
    [_content release];
    [super dealloc];


}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubview];
        
        
        
    }

    
    return self;

}


- (void)createSubview{


    self.icon_url = [[UIImageView alloc]init];
    [self.contentView addSubview:self.icon_url];
    
    
    self.content = [[UILabel alloc]init];
    [self.contentView addSubview:self.content];
    
    
    self.create_time = [[UILabel alloc]init];
    
    [self.contentView addSubview:self.create_time];
    
    
    
    self.name = [[UILabel alloc]init];
    [self.contentView addSubview:self.name];
    
    
    
    [self.icon_url release];
    [self.create_time release];
    [self.content release];
    
    [self.name release];
    
    
    
    
    



}


- (void)layoutSubviews{

    [super layoutSubviews];
    self.icon_url.frame = CGRectMake(30.f, 30.f, 60.f, 60.f);
    self.icon_url.layer.masksToBounds = YES;
    self.icon_url.layer.cornerRadius = 30;
    
    
    
    
    self.name.frame = CGRectMake(120, 50, 150, 30);
    self.content.frame = CGRectMake(10, 100, WIDTH - 10, [[self class]heightForLabel:self.content.text]);
    self.create_time.frame = CGRectMake(10, 100 + [[self class]heightForLabel:self.content.text] , 180, 30);

    



}

+ (CGFloat)heightForLabel:(NSString *)text{
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake(WIDTH - 20, 0) options: NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil];
    
    return rect.size.height;
}

+ (CGFloat)heightForCell:(SpeakModel *)model{
    
    CGFloat height =  [SpeakTwoCell heightForLabel:model.content];
    
    
    return height + 150;

}


- (void)passModel:(SpeakModel *)model{


    
    
    [self.icon_url sd_setImageWithURL:[NSURL URLWithString:model.icon_url] placeholderImage:[UIImage imageNamed:@"jz"]];
    self.name.text = model.name;
    self.content.text = model.content;
    self.content.numberOfLines = 0;
    self.content.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor lightGrayColor]);
    
    
    
    
    self.create_time.text = model.create_time;



}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
